package org.smart4j.plugin.security.realm;

import org.apache.shiro.realm.jdbc.JdbcRealm;
import org.smart4j.framework.helper.DatabaseHelper;
import org.smart4j.plugin.security.SecurityConfig;
import org.smart4j.plugin.security.password.Md5CredentialsMatcher;

/**
 * description: 基于Smart 的JDBC Realm （需要提供 smart.plugin.security.jdbc.* 配置项）
 * @version v1.0
 * @author w
 * @date 2018年11月4日下午10:05:45
 **/
public class SmartJdbcRealm extends JdbcRealm {

	public SmartJdbcRealm() {
		super.setDataSource(DatabaseHelper.getDataSource());
		super.setAuthenticationQuery(SecurityConfig.getJdbcAuthQuery());
		super.setUserRolesQuery(SecurityConfig.getJdbcRolesQuery());
		super.setPermissionsQuery(SecurityConfig.getJdbcPermissionsQuery());
		super.setPermissionsLookupEnabled(true);
		// 使用 MD5加密算法 
		super.setCredentialsMatcher(new Md5CredentialsMatcher());
	}
	
	
	
}
